package com.tyc.wx.service;

import com.alibaba.fastjson.JSONObject;
import com.tyc.wx.utills.AppUtill;
import com.tyc.wx.utills.PublicUtill;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @Description: java类作用描述
 * @Author: tyc
 * @CreateDate: 2020/12/30 10:04
 */

public class WxServiceImpl implements WxService{
    AppUtill appUtill;
    PublicUtill publicUtill;

    public WxServiceImpl(AppUtill appUtill, PublicUtill publicUtill) {
        this.appUtill = appUtill;
        this.publicUtill = publicUtill;
    }


    @Override
    public String getAppAccessToken() {
        return appUtill.getAccessToken();
    }

    @Override
    public JSONObject getAppLoginInfo(String code) {
        return appUtill.getByCode(code);
    }

    @Override
    public JSONObject getAppUserPhone(String encryptedData,String session_key, String  iv) {
        return appUtill.getPhone(encryptedData,session_key,iv);
    }

    @Override
    public String getPubAccessYoken() {
        return publicUtill.getAccessToken();
    }

    @Override
    public Map<String, String> xmlToMap(HttpServletRequest request) {
        return publicUtill.xmlToMap(request);
    }

    @Override
    public String getPubH5Openid(String code) {
        return publicUtill.getOpenidByCode(code);
    }

    @Override
    public boolean sendTemplateMessage(String access_token, String message) {
        return publicUtill.sendTemplateMessage(access_token, message);
    }

    @Override
    public Boolean sendTemplateMessageToApp(String access_token,String message) {
        return appUtill.sendTemplateMessage(access_token,message);
    }

    @Override
    public Boolean authenticate(String signature, String timestamp, String nonce) {
        return publicUtill.authenticate(signature, timestamp, nonce);
    }
}
